@model Adams.Admin.DataTransfer.Sitemap.Index.PageLoad
@{
    Layout = "~/Views/Sitemap/_Layout.cshtml";
}
@section Head{
    <link rel="stylesheet" type="text/css" href="@Url.Content("/Content/Sitemap/index.css")" />
}
@if (!string.IsNullOrEmpty(ViewBag.Message))
{
    <div class="notification success png_bg">
        <a href="#" class="close">
            <img src="@Url.Content("/Content/images/cross_grey_small.png")" title="Close this notification"
            alt="close" /></a>
        <div>
            @if (ViewBag.Message == "1")
            {
                <b>Successfully saved node!</b>
            }
            else if (ViewBag.Message == "2")
            {
                <b>Successfully deleted node!</b>
            }
        </div>
    </div>
}
<div class="content-box">
    <div class="content-box-header">
        <h3>
            Nodes</h3>
    </div>
    <div class="content-box-content">
        <a href="#" id="create">Create New Section</a>
        @ShowNodes(Model.HomeNode, true)
        <div class="clear">
        </div>
        <div id="msg">
        </div>
    </div>
</div>
@helper ShowNodes(Adams.Shared.Entities.Sitemap.Node node, bool isHome)
    {
        
    <ul id="@string.Format("p_{0}", node.ID)" class="nodes @(node.ChildNodes.Count == 0 || !isHome ? "hidden" : "")">
        @foreach (var n in node.ChildNodes)
        {
            <li id="@string.Format("n_{0}", n.ID)" class="@(isHome ? "level1" : "level2")">
            <a href="#" class="showhide">
                    <img src="@Url.Content("/Content/images/tree_plus.png")" /></a>            
            <span>@n.Title</span>
                @if (n.ChildNodes.Count == 0)
                {
                    <a href="#" class="delete">
                        <img src="@Url.Content("/Content/images/cross.png")" alt="delete" /></a>
                }
                <a href="#" class="edit">
                    <img src="@Url.Content("/Content/images/pencil.png")" alt="Edit" /></a> <a href="#"
                        class="add">
                        <img src="@Url.Content("/Content/images/add.png")" alt="Add" /></a>
                @ShowNodes(n, false)
            </li>
        }
    </ul>
}
<div id="editbox" class="content-box hidden" style="width: 50%;">
    <div class="content-box-header">
        <h3>
            Edit node</h3>
    </div>
    <div class="content-box-content">
        <form action="" method="post">
        <p>
            <label>
                Title</label>
            <input class="text-input medium-input" type="text" id="Title" value="" />
            <br />
            <small>Title of the node</small>
        </p>
        <p>
            <label>
                Url</label>
            <input class="text-input medium-input" type="text" id="Url" value="" />
            <br />
            <small>The url for the node</small>
        </p>
        <p>
            <input class="button" id="submit" type="button" value="Submit" />
            <input class="button" id="cancel" type="button" value="Cancel" />
        </p>
        <div class="clear">
        </div>
        <!-- End .clear -->
        <input id="NodeID" type="hidden" value="" />
        <input id="ParentNodeID" type="hidden" value="" />
        <input id="DisplayOrder" type="hidden" value="" />
        </form>
    </div>
</div>
@section Scripts {
    <script type="text/javascript" src="@Url.Content("/Scripts/Sitemap/index.js")"></script>
}
